using System.Collections;
using UnityEngine;

public class GroundCrack : MonoBehaviour
{
	public SpriteRenderer sr;

	private Color c;

	private void OnEnable()
	{
		sr.sprite = Sprites.instance.groundCrackSpriteList[Random.Range(0, 4)];
		sr.transform.localScale = new Vector2((Random.Range(0, 2) != 0) ? 1 : (-1), 1f);
		c = sr.color;
		sr.color = new Color(c.r, c.g, c.b, 1f);
		StartCoroutine(IE_Show());
	}

	private IEnumerator IE_Show()
	{
		yield return new WaitForSeconds(3f);
		for (float f = 1f; f > 0f; f -= Time.fixedDeltaTime * 2f)
		{
			sr.color = new Color(c.r, c.g, c.b, f);
			yield return new WaitForFixedUpdate();
		}
		base.gameObject.SetActive(false);
	}
}
